package com.jsmtr.rms.controller.UserResumeView;

import com.jsmtr.rms.service.IDoResumeService;
import com.jsmtr.rms.utils.ResultBean;
import com.jsmtr.rms.utils.StringTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 应聘者简历变更控制
 * @author: cyx
 * @description:
 * @date: Created in 2019/2/19 15:08
 * @modified by:
 */
@Controller
public class UserResumeChangeInfoController {
    @Resource
    private IDoResumeService doResumeService;

    @ResponseBody
    @RequestMapping(value = "/UserResume/RecommendPostHistory")
    public ResultBean RecommendPostHistory(HttpServletRequest request, HttpServletResponse response){
        String cardNo=request.getParameter("cardno");
        ResultBean resultBean=new ResultBean();
        try {
            List<Map<String,Object>> historyList= doResumeService.getRecommendHistory(cardNo);
            if(historyList!=null&&historyList.size()>0){
                List<Map> resultList=new ArrayList<>();
                for (Map<String,Object> history : historyList) {
                    Map resultMap=new HashMap<String,String>();
                    resultMap.put("cardno",history.get("CARDNO"));
                    resultMap.put("name",history.get("NAME"));
                    resultMap.put("oldjob",history.get("OLDJOB"));
                    resultMap.put("nowjob",history.get("NOWJOB"));
                    resultMap.put("oldrfid",history.get("OLDRFID"));
                    resultMap.put("oldrid", history.get("OLDRID"));
                    resultMap.put("oldnrid", history.get("OLDNRID"));
                    resultMap.put("oldnjname",history.get("OLDNJNAME"));
                    resultMap.put("oldchangedate",history.get("OLDCHANGEDATE"));
                    resultMap.put("newrfid",history.get("NEWRFID"));
                    resultMap.put("neworid",history.get("NEWORID"));
                    resultMap.put("newnrid",history.get("NEWNRID"));
                    resultMap.put("newnjname",history.get("NEWNJNAME"));
                    resultMap.put("newchangedate",history.get("NEWCHANGEDATE"));
                    resultMap.put("rflowname",history.get("RFLOWNAME"));
                    resultMap.put("pname",history.get("PNAME"));
                    resultMap.put("recommenddate",history.get("RECOMMENDDATE"));
                    resultList.add(resultMap);
                }
                resultBean.setTotalResult(String.valueOf(historyList.size()));
                resultBean.setState(true);
                resultBean.setMessage("操作成功!");
                resultBean.setDatas(resultList);
            }else{
                resultBean.setState(false);
                resultBean.setMessage("该人员尚未参加应聘!");
                resultBean.setDatas(null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return  resultBean;
        }
        return resultBean;
    }

}
